package com.night.administration.controller;

import com.night.administration.service.CourseService;
import com.night.common.entity.ResultVo;
import com.night.common.entity.administration.Course;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: TeacherController
 * @Description: //TODO
 * @author: LZJ
 * @date: 2022/10/23-14:15
 * @version: v1.0
 */
@RestController
@RequestMapping("/api/v1/course")
public class CourseController {
    @Resource
    private CourseService courseService;

    @PostMapping("/list")

    public ResultVo<Course> getAllByCondition(@RequestBody Course course) {
        return new ResultVo(courseService.getByCondition(course));
    }

    @PostMapping("/add")
    public ResultVo<String> add(@RequestBody Course course) {
        courseService.insert(course);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/update")
    public ResultVo<String> update(@RequestBody Course course) {
        courseService.update(course);
        return ResultVo.SUCCESS;
    }

}
